package com.example.template.commontable.controller;


import com.example.template.commontable.service.impl.TableColumnServiceImpl;
import com.example.template.core.controller.BaseControllerCrud;
import com.example.template.commontable.entity.TableColumn;
import com.example.template.core.controller.BaseModelController;
import com.example.template.core.model.AppJsonMessage;
import com.example.template.core.model.CommonConst;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javafx.beans.DefaultProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
*
 * @author meko
 * @date 2019/11/28 10-11-00
 */
@Api(tags = {"表头数据"})
@RestController
@RequestMapping("/tableColumn")
public class TableColumnController extends BaseModelController {

    @Autowired
    private TableColumnServiceImpl tableColumnService;

    @ApiOperation(value = "查询所有实体")
    @GetMapping("")
    public AppJsonMessage getAllEntity(@RequestParam(defaultValue = "1") Integer page,
                                       @RequestParam(defaultValue = "20") Integer size,
                                       TableColumn t){
        List<TableColumn> dataList = tableColumnService.selectAll(t,page,size);
        return this.getJsonMessage(CommonConst.SUCCESS,dataList);
    }

    @ApiOperation(value = "根据表名查询表头数据")
    @GetMapping("/{{tableName}}")
    public AppJsonMessage getEntityByEntity( @PathVariable("{tableName}") String tableName){
        List<TableColumn> tableColumns = tableColumnService.getEntityByTableName(tableName);
        return this.getJsonMessage(CommonConst.SUCCESS,tableColumns);
    }

}


